package com.zzc.legou.service.item.controller;

import com.zzc.legou.core.controller.BaseController;
import com.zzc.legou.core.po.ResponseBean;
import com.zzc.legou.item.entity.Spu;
import com.zzc.legou.service.item.service.ISpuService;
import io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Title:
 */
@RestController
@RequestMapping(value = "/spu")

public class SpuController extends BaseController<ISpuService, Spu> {

    @ApiOperation(value="保存商品信息", notes="保存商品信息")
    @PostMapping("/save-spu")
    public ResponseBean saveSpu(@RequestBody Spu spu) throws Exception{
        ResponseBean responseBean = new ResponseBean();
        try {
            this.service.saveSpu(spu);
        } catch (Exception e){
            responseBean.setSuccess(false);
            responseBean.setMsg("保存失败");
        }
        return responseBean;
    }

    @ApiOperation(value="查询所有", notes="查询所有spu")
    @GetMapping("/list-all")
    public List<Spu> selectAll(){
        return this.service.list();
    }
}
